<template>
  <a-col :xl="{ span: 12 }" :lg="{ span: 12 }" :md="{ span: 12 }">
    <a-form-item :label="data.fieldAliase" :labelCol="labelCol" :wrapperCol="wrapperCol">
      <a-date-picker style="width: 100%;" v-decorator="[`${data.fieldCode}`,{rules:rules,initialValue:moment(data.defaultValue)}]" />
    </a-form-item>
  </a-col>

</template>
<script>
  import moment from 'moment'
  export default {
    name: 'InputDate',
    components: {},
    props: {
      form: {
        type: Object,
        required: true
      },
      data: {
        type: Object,
        required: true
      }
    },
    data () {
      return {
        labelCol: {
          xs: {
            span: 24
          },
          sm: {
            span: 3
          }
        },
        wrapperCol: {
          xs: {
            span: 24
          },
          sm: {
            span: 20
          }
        },
        rules: []
      }
    },
    created () { this.init() },
    methods: {
      init () {
        const data = this.data
        this.rules = [
          { required: data.isRequired, message: '请输入' + data.fieldAliase }
        ]
      },
      moment (date) {
        return moment(date || new Date())
      }
    }
  }
</script>
